package com.alex.j2se.oop;

public class ExtendTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Base b = new Sub();    
        System.out.println(b.x);  
	}

}


class Base {    
    int x = 10;    
    
    public Base() {    
        this.printMessage();    
        x = 20;    
    }    
    
    public void printMessage() {    
        System.out.println("Base.x = " + x);    
    }    
}  


class Sub extends Base {    
    int x = 30;    
    
    public Sub() {    
        this.printMessage();    
        x = 40;    
    }    
    
    public void printMessage() {    
        System.out.println("Sub.x = " + x);    
    }    
}    